<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>

    <link href="../assets/global/plugins/font-awesome/css/font-awesome.min.css" rel="stylesheet" type="text/css" />
    <link href="../assets/global/plugins/bootstrap/css/bootstrap.min.css" rel="stylesheet" type="text/css" />
    <link href="../assets/global/plugins/simple-line-icons/simple-line-icons.min.css" rel="stylesheet" type="text/css" />
    <link href="../assets/global/plugins/bootstrap/css/bootstrap.min.css" rel="stylesheet" type="text/css" />

    <link href="../assets/global/css/components.min.css" rel="stylesheet" id="style_components" type="text/css" />
    <link href="../assets/global/css/plugins.min.css" rel="stylesheet"  type="text/css" />

    <link href="../assets/global/plugins/jstree/dist/themes/default/style.min.css" rel="stylesheet" type="text/css">

    <link rel="stylesheet" href="../assets/global/plugins/layui/css/layui.css"/>
    <link rel="stylesheet" href="../assets/custom/css/tabstyle.css"/>
    <link rel="stylesheet" href="../assets/custom/css/change_form.css"/>
    <link rel="stylesheet" href="../assets/custom/css/changeother.css"/>
    <link rel="stylesheet" href="../assets/custom/css/taskDispatch.css"/>
</head>
<body>
<div class="portlet light hFill">
    <div class="portlet-title tabbable-line">
        <ul class="nav nav-tabs">
            <li class="active">
                <a href="#" data-toggle="tab" data-requencyType = '0'>全部 </a>
            </li>
            <li>
                <a href="#" data-toggle="tab" class="hasTime" data-requencyType = '2'>每天运行 </a>
            </li>
            <li >
                <a href="#" data-toggle="tab" class="hasTime" data-requencyType = '3'> 每周运行</a>
            </li>
            <li >
                <a href="#" data-toggle="tab" class="hasTime" data-requencyType = '4'> 每月运行 </a>
            </li>
            <li>
                <a href="#" data-toggle="tab" class="hasTime" data-requencyType = '1'> 时间间隔 </a>
            </li>
            <li >
                <a href="#" data-toggle="tab" data-requencyType = '5'> 未设定时间 </a>
            </li>
        </ul>
    </div>
    <div class="portlet-body">
       <!-- <div class="tab-content">
            <div class="tab-pane active" id="portlet_tab1">

            </div>
            <div class="tab-pane" id="portlet_tab2">
                <div class="headerTime clearfix">
                    <div class="leftTime fl">
                        <a href="javascript:;" class="btn default">1 : 50</a>
                        <a href="javascript:;" class="btn default">3 : 50</a>
                        <a href="javascript:;" class="btn default">5 : 50</a>
                        <a href="javascript:;" class="btn default">7 : 50</a>
                        <a href="javascript:;" class="btn default">9 : 50</a>
                    </div>
                    <a href="javascript:;" class="fr btn default refresh">刷新</a>
                </div>
            </div>
            <div class="tab-pane" id="portlet_tab3">
                <div class="headerTime clearfix">
                    <div class="leftTime fl">
                        <a href="javascript:;" class="btn default">1 : 50</a>
                        <a href="javascript:;" class="btn default">3 : 50</a>
                        <a href="javascript:;" class="btn default">5 : 50</a>
                        <a href="javascript:;" class="btn default">7 : 50</a>
                        <a href="javascript:;" class="btn default">9 : 50</a>
                    </div>
                    <a href="javascript:;" class="fr btn default refresh">刷新</a>
                </div>
            </div>
            <div class="tab-pane" id="portlet_tab4">
                <div class="headerTime clearfix">
                    <div class="leftTime fl">
                        <a href="javascript:;" class="btn default">1 : 50</a>
                        <a href="javascript:;" class="btn default">3 : 50</a>
                        <a href="javascript:;" class="btn default">5 : 50</a>
                        <a href="javascript:;" class="btn default">7 : 50</a>
                        <a href="javascript:;" class="btn default">9 : 50</a>
                    </div>
                    <a href="javascript:;" class="fr btn default refresh">刷新</a>
                </div>
            </div>
            <div class="tab-pane" id="portlet_tab5">
                <div class="headerTime clearfix">
                    <div class="leftTime fl">
                        <a href="javascript:;" class="btn default">1 : 50</a>
                        <a href="javascript:;" class="btn default">3 : 50</a>
                        <a href="javascript:;" class="btn default">5 : 50</a>
                        <a href="javascript:;" class="btn default">7 : 50</a>
                        <a href="javascript:;" class="btn default">9 : 50</a>
                    </div>
                    <a href="javascript:;" class="fr btn default refresh">刷新</a>
                </div>
            </div>
            <div class="tab-pane" id="portlet_tab6">

            </div>
        </div>-->
        <div class="headerTime clearfix display_none">
            <div class="leftTime fl">

            </div>
            <a href="javascript:;" class="fr btn default refresh">刷新</a>
        </div>
        <div class="bodyTask hFill">
            <div class="left_tree hFill fl">
                <h3 class="showTime">全部</h3>
                <div class="taskSearch">
                    <input type="text" oninput="" onporpertychange="" class="searchTuName">
                    <i class="fa fa-search"></i>
                </div>
                <div class="taskUtil">
                    <button class="btn default taskAdd" title="新增"><i class="glyphicon glyphicon-plus"></i></button>

                    <div id="tree_8"></div>
                </div>
            </div>
            <div class="right_er hFill">
                <div class="top_nav">
                    <div class="left_navs ">
                        <div class="middle_navs" style="margin-left: 0; border-left: 1px solid #ddd">
                            <div id="page-tab-content">	<ul id="menu-list" class="nav nav-pills ">
                            </ul></div></div>
                        <button class="tab-btn fa fa-angle-left" id="page-prev"></button>
                        <button class="tab-btn  fa fa-angle-right" id="page-next"></button>
                    </div>
                </div>
                <div class="erBox">
                    <!--<div class="portlet_list hFill">
                        <iframe src="../assets/custom/draw/processSet.html" width="100%" height="100%" frameborder="0"></iframe>
                    </div>-->
                    <div class="tab-content hFill">

                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
</body>
<script src="../assets/global/plugins/jquery.min.js" type="text/javascript"></script>
<script src="../assets/global/plugins/bootstrap/js/bootstrap.min.js" type="text/javascript"></script>

<script src="../assets/global/scripts/app.min.js" type="text/javascript"></script>

<script src="../assets/global/plugins/jstree/dist/jstree.js" type="text/javascript"></script>
<script src="../assets/global/plugins/jstree/dist/ui-tree.min.js" type="text/javascript"></script>
<script src="../assets/global/plugins/jstree/dist/jquery-ui.js"></script>

<script src="../assets/global/plugins/layui/layui.all.js"></script>
<script src="../assets/custom/js/tab.js"></script>
<script>
var  base = "http://192.168.0.130:8094";
var requencyType = 0 , //当前时间类型
    tree =  $("#tree_8"),   //jstree对象
    refreshTimeData,        //jstree刷新时的数据对象
    navValue,                //jstree的title
    hour,              //小时
    minutes,            //分钟
    weekday,            //周
    dayOfMonth,          // 一个月第几天
    intervalMinutes,        //时间间隔分钟
    intervalSeconds,      //时间间隔秒
    fromTime,              //起始时间
    toTime,             //中止时间
    taskTimeResponseData,            //单元时间点响应的数据
    TimeTypeResponseData,             //不同的时间类型响应的数据
    taskId,                  //任务单元id
    firstData = 0,          //运行某个时间点（默认是第一个）
    firstTask,              //第一个任务单元
    timeTypeRequestData ={'requencyType':0,'layoutType':'graph','bizType': 'dxflow'},    //时间类型请求的data数据
    taskTimeRequestData = {'layoutType':'graph'};                                       //任务单元时间点请求数据


var processDispatch = {
    //任务单元时间点请求封装
    taskTimeRequest : function(){
        $.ajax({
            url : base + '/rest/ts/findfreqList',
            type : 'GET',
            dataType : 'JSON',
            async: false,
            data : taskTimeRequestData,
            success : function(data){
                taskTimeResponseData = data; //得到时间点的数据
           //     console.log(taskTimeResponseData)

            },
            error : function (data) {
                layer.open({
                    title: '提示'
                    , content: '网络异常',
                    shade: 0
                });
            }
        });
    },

    //不同的时间类型请求封装
    TimeTypeRequest: function () {
        $.ajax({
            url : base + '/rest/ts/findTaskUnit',
            type : 'GET',
            dataType : 'JSON',
            async: false,
            data : timeTypeRequestData,
            success : function(result){
             //   console.log(result);
                TimeTypeResponseData = result;
                refreshTimeData = processDispatch.dataJson(result);
                tree.jstree({
                    core: {
                        themes: {
                            responsive: !1,
                            "icons" : false,
                            "dots" : false
                        },
                        check_callback: !0,
                        data : function (obj,callback) {

                            callback.call(this, processDispatch.dataJson(result));
                        }
                    },
                    "types" : {
                        "default" : {
                            "icon" : "glyphicon glyphicon-flash"
                        },
                        "file" : {
                            "icon" : "glyphicon glyphicon-ok"
                        }
                    },
                    plugins: ['wholerow','types',"search","contextmenu"],
                    //-------------------------------------------------------------------------
                    "contextmenu": {
                        "items": {
                            "create": null,
                            //"rename": null,
                            "remove": null,
                            "ccp": null,
                            "修改名称": {
                                "label": "修改名称",
                                "action" : function (data) {
                                    var inst = $.jstree.reference(data.reference),
                                        obj = inst.get_node(data.reference);
                                    inst.edit(obj);
                                },
                                "icon" : 'icon-note'
                            },
                            "调度时间": {
                                "label": "调度时间",
                                "action": function(data) {
                                    var inst = jQuery.jstree.reference(data.reference);
                                    obj = inst.get_node(data.reference);
                                    taskId = obj.id;
                                      layer.open({
                                          type : 2,
                                          content : ['dispatchTime.html'],
                                          area : ['900px','600px']
                                      })
                                },
                                "icon" : 'icon-clock'
                            },
                            "启用/停用": {
                                "label": "启用/停用",
                                "action": function(data,a) {
                                    var inst = jQuery.jstree.reference(data.reference);
                                    obj = inst.get_node(data.reference);
                                    data.reference.parents('.jstree-leaf').toggleClass('outageStatus'); //启用禁用切换
                                    $.ajax({
                                        url : base + '/rest/ts/enableTask',
                                        type : 'GET',
                                        dataType : 'JSON',
                                        data : {tuId: obj.id},
                                        success :function (data) {
                                            console.log(data)
                                        }
                                    })
                                },
                                "icon" : 'icon-control-pause'
                            },
                            "删除": {
                                "label": "删除",
                                "action": function(data,a) {
                                    var inst = jQuery.jstree.reference(data.reference);
                                    obj = inst.get_node(data.reference);
                                   var  tuId = obj.id;
                                    $.ajax({
                                        url : base + '/rest/ts/deleteTaskUnit',
                                        type : 'GET',
                                        dataType : 'JSON',
                                        data : {tuId: tuId},
                                        success :function (result) {
                                            console.log(data);
                                         //   console.log(data.reference[0].id);
                                            var currentHref = "#g" + data.reference[0].id;
                                         //   console.log(currentHref);
                                            var currentEle = $("i[data-href='"+currentHref+"']");
                                       //     console.log($("a[ href='"+currentHref+"']"));
                                            if(currentEle.length){
                                                CloseTask(currentEle);
                                            }
                                            updateTree();
                                        }
                                    })
                                },
                                "icon" : 'glyphicon glyphicon-remove'
                            }
                        }
                    }
                    //-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- //

                });

            }
        });
    },

    //jstree的json数据封装
    dataJson : function(result){
        var arr = [] ;
        var obj = {
            "id": 8899,
            "parent": "#", //最上层父类id为 #
            "state": {"opened": true}, //默认展开所有
            "text": "任务单元"
        };
        arr.push(obj);
        for (var i = 0; i < result.data.length; i++) {
            var objSub = {
                "id": result.data[i].tuId,
                "parent": 8899, //最上层父类id为 #
                "state": {"opened": true}, //默认展开所有
                "text": result.data[i].tuName,
            };
            if(result.data[i].status == 0){
                objSub.li_attr = {'class': 'outageStatus'}
            }
            if(i === 0){
                objSub.state.selected = true
            }
            arr.push(objSub);
        }
       // console.log(arr);
        return arr;
    },

    //初始默认添加第一个页面
    addFirstTask : function (result) {
        if(result.data.length > 0){
            //   console.log(result.data[0]);
            firstTask = result.data[0];
            var name = firstTask.tuName;
            var url =  '../assets/custom/draw/processSet.html';
            var this_id = firstTask.tuId +'_anchor';
            //  console.log(name);
            addTab(name,url,this_id);

        }
    },

    //processDispatch页面初始化
    init : function(){
        this.taskTimeRequest();
        this.TimeTypeRequest();
        this.addFirstTask(TimeTypeResponseData);
    }
};
processDispatch.init();  //调度流程初始化

//搜索任务单元
$('.searchTuName').bind('input propertychange', function() {
    timeTypeRequestData.tuName = $(this).val(); //搜素关键字（参数）
    updateTree()  //更新tree
});


 //点击时间点或更新时间点
 $('.headerTime').on('click','a',function(){
     if($(this).hasClass('refresh')){ //更新时间点
      //   console.log(requencyType);
         $('.bodyTask').height(bodyTaskH(requencyType));    //内容高度
         taskTimeRequestData.requencyType = requencyType;   //时间类型切换
         processDispatch.taskTimeRequest();                 //任务单元时间点请求
         headerTimeUpdate();
     }else if($(this).hasClass('timePoint')){ //点击时间点
         $('.showTime').text(navValue + '--'+$(this).text());   //showTime切换
         firstData = $(this).index();   //第几个时间点
         headerTimeUpdate();
         updateTree(); //更新tree
     }
     $('.timePoint:eq('+firstData+')').addClass('TimeActive');  //选中的时间点
 });

 //点击不同的时间类型
    $('.nav-tabs').on('click','li>a',function(){

        $('.showTime').text($(this).text()); //时间类型显示
        navValue = $('.showTime').text();   //时间类型
        $('.searchTuName').val(''); //搜索为空
        $("#page-tab-content .nav-pills").children().remove(); //删除tab栏列表
        $('.tab-content').children().remove();                  //删除tab栏对应的content

        requencyType = parseInt($(this).attr('data-requencyType')); //改变时间类型

        if($(this).hasClass('hasTime')){   //有时间点类型
            $('.headerTime').removeClass('display_none'); //时间点显示
            $('.taskAdd').addClass('display_none');         //新增任务单元隐藏

            //改变类型逻辑部分
            taskTimeRequestData.requencyType = requencyType;  //切换类型
            processDispatch.taskTimeRequest();              //任务单元时间点请求
            firstData = 0;                              //运行时间点为第一个
        //    console.log(requencyType);
            headerTimeUpdate();
            $('.timePoint:eq('+firstData+')').addClass('TimeActive');   //时间点被选中

        }else {                             //没有时间点类型
            $('.headerTime').addClass('display_none');      //时间点隐藏
            $('.taskAdd').removeClass('display_none');      //新增任务单元显示
            $("#tree_8").removeClass('display_none');       //tree显示
            if (requencyType === 0){
                timeTypeRequestData = {'requencyType':0,'layoutType':'graph','bizType': 'dxflow'}
            }else if(requencyType === 5){
                timeTypeRequestData = {'requencyType':5,'layoutType':'graph','bizType': 'dxflow'}
            }
        }

        $('.bodyTask').height(bodyTaskH(requencyType)); //内容高度
        updateTree();
        processDispatch.addFirstTask(TimeTypeResponseData);

    });

    //点击新增按钮时
    $('.taskAdd').click(function(){
      var index =  layer.open({
            type : 1,
            title : '新增任务单元',
            area : ['600px','400px'],
            content : '  <label style="position: absolute;top: 35%;left: 50%;transform: translateX(-50%)"><span class="margin-right-20">任务单元名：</span><input type="text"  class="addTaskName" style="width: 200px;"></label> ',
            btn : ['保存','关闭'],
            yes : function(){
             var val =  Trim($('.addTaskName').val(),'g') ;

            if(val != ''){
                console.log(val);
                  $.ajax({
                    url: base + '/rest/ts/createTaskUnit',
                    dataType : 'JSON',
                    type : 'GET',
                    async: false,
                    data : {'tuName':val,'layoutType':'graph','bizType':'dxflow'},
                    success : function (data) {

                        updateTree();
                    }

                });

                layer.close(index)
            }

            }
        })
    });

    //修改任务单元名
tree.on("rename_node.jstree", function(e, data){
    console.log(data.node.id,data.node.text);
    $.ajax({
        url : base+ '/rest/ts/updateTuName',
        type : 'GET',
        dataType : 'JSON',
        data : {'tuId':data.node.id,'tuName':data.node.text,'layoutType':'graph','bizType':'dxflow'},
        success : function(data){
            console.log(data)

        }
    })
});

//点击任务单元时
$('.taskUtil').on('click','a',function(){
   // console.log($(this).parent().attr("aria-level"));
    if($(this).parent().attr("aria-level") === "1"){
        return;
    }
    firstTask.tuId = $(this).attr('id');
    var name = $(this).text();
    var url =  '../assets/custom/draw/processSet.html';
    var this_id = $(this).attr('id');
  //  console.log(name);
    addTab(name,url,this_id);
    $('.bodyTask').height(bodyTaskH(requencyType));


});

//页面宽度改变时
$(window).resize(function(){
    $('.bodyTask').height(bodyTaskH(requencyType));
});

//时间点和tree的切换
function headerTimeUpdate(){
        $('.timePoint').remove(); //删除时间点
      //  console.log( $.isEmptyObject(taskTimeResponseData.object));
        if(!$.isEmptyObject(taskTimeResponseData.object)){      //如果没有时间点数据
            $("#tree_8").removeClass('display_none');           //tree显示
            var currentTime,firstTime, //每一个时间点字符串 和 选中的时间点字符串
                timeArr = taskTimeResponseData.object[requencyType]; //每个类型时间点数组

            $.each(timeArr,function (i,v) {     //遍历时间点数组

                if (requencyType === 2){
                    currentTime = v.hour + ':' + v.minutes;

                    hour = timeArr[firstData].hour;
                    minutes = timeArr[firstData].minutes;
                    firstTime='--'+hour+':'+minutes;

                    timeTypeRequestData = {'requencyType':2,'layoutType':'graph','bizType': 'dxflow','hour':hour,'minutes':minutes}
                }
                else if(requencyType === 3){

                    currentTime = '周' + weekChange(v.weekday) + '&nbsp;'+ v.hour + ':' + v.minutes;

                  var  weekdayShow = weekChange(timeArr[firstData].weekday);
                    weekday = timeArr[firstData].weekday;
                    hour = timeArr[firstData].hour;
                    minutes = timeArr[firstData].minutes;
                    firstTime='--'+'周' + weekdayShow + '&nbsp;'+ hour + ':' + minutes;

                    timeTypeRequestData = {'requencyType':3,'layoutType':'graph','bizType': 'dxflow','weekday':weekday ,'hour':hour,'minutes':minutes}
                }
                else if(requencyType === 4) {
                    currentTime = '第' + v.dayOfMonth + '天' + '&nbsp;'+ v.hour + ':' + v.minutes;

                    dayOfMonth = timeArr[firstData].dayOfMonth;
                    hour = timeArr[firstData].hour;
                    minutes = timeArr[firstData].minutes;
                    firstTime='--'+'第'+dayOfMonth + '天'+ '&nbsp;'+ hour+':'+minutes;

                    timeTypeRequestData = {'requencyType':4,'layoutType':'graph','bizType': 'dxflow','dayOfMonth':dayOfMonth ,'hour':hour,'minutes':minutes}
                }
                else if(requencyType === 1){

                    intervalMinutes = timeArr[firstData].intervalMinutes;
                    intervalSeconds = timeArr[firstData].intervalSeconds;
                    fromTime = timeArr[firstData].fromTime;
                    toTime = timeArr[firstData].toTime;

                    if (v.fromTime === null ){
                        currentTime = '每'+ v.intervalMinutes + '分' + v.intervalSeconds + '秒';
                    }else {
                        currentTime = '每'+ v.intervalMinutes + '分' + v.intervalSeconds + '秒'+ '(' +v.fromTime + '-' + v.toTime + ')';
                    }
                    firstTime='--'+'每'+intervalMinutes +'分'+intervalSeconds + '秒'+  (fromTime!==null?'(' +fromTime + '-' + toTime + ')':'') ;
                    timeTypeRequestData = {'requencyType':1,'layoutType':'graph','bizType': 'dxflow','intervalMinutes':intervalMinutes,'intervalSeconds':intervalSeconds,"fromTime":fromTime,'toTime':toTime}
                }

             //   console.log(currentTime);
                $('.headerTime>.leftTime').append('<a href="javascript:;" class="timePoint">'+currentTime+'</a>'); //时间点dom添加
                $('.showTime').html(navValue + firstTime);         //showTime显示对应事件类型+时间点
            });
        //    console.log($('.timePoint:eq('+firstData+')'));
            $('.timePoint:eq(firstData)').addClass('TimeActive');   //时间点被选中

        }
        else {  //如果没有时间点数据
            timeTypeRequestData = {'requencyType':requencyType,'layoutType':'graph','bizType': 'dxflow'};
            $("#tree_8").addClass('display_none');      //tree隐藏
            $('.showTime').html(navValue);      //只显示时间类型(没有时间点)

        }
    }

    //字符串去空格
function Trim(str,is_global) {
    var result;
    result = str.replace(/(^\s+)|(\s+$)/g,"");
    if(is_global.toLowerCase()=="g")
    {
        result = result.replace(/\s/g,"");
    }
    return result;
}

//添加tab栏
 function addTab(name,url,this_id){
    //	var this_id = $(this).attr('id');
    $("#page-tab-content .nav-pills .active").removeClass("active");

    if($('#g'+this_id+'').length === 0){
        var strp = this_id.replace("_anchor", "");
        $('.tab-content').append("<div id='g"+this_id+"' data-tuid='"+strp+"' class='tab-pane active' style=\"height:100%;\"><iframe  src='"+url+"'  width='100%' height='100%' scrolling='no' style=\"border:none\"></iframe></div>");
        $('#g'+this_id+'').siblings().removeClass("active");
        $("#page-tab-content .nav-pills").append(" <li class='active' data-toggle='tooltip' data-placement='bottom' title='"+name+"'><a href='#g"+this_id+"'  data-toggle=\"tab\" role=\"tab\" > <span>"+name+"</span><i class='fa fa-close' data-href='#g"+this_id+"'></i></a></li>");
    }else {
        $("#page-tab-content .nav-pills .active").removeClass("active");
        $("a[ href='#g"+this_id+"']").parent().addClass('active');
        $('#g'+this_id+'').addClass("active").siblings().removeClass("active");
    }

    createmove();  //添加时移动tab栏
    $('.fa-close').unbind('click').click(function(){ //关闭tab栏选项时
        /*var this_li = $(this).parent().parent();
        var this_li_prev = $(this).parent().parent().prev();
        var portlet_id = $(this).parent().attr('href').substr(1);
        var portlet_id_obj = $('#'+portlet_id+'');
        var current_cotent = 	portlet_id_obj;
        var current_cotent_prev = portlet_id_obj.prev();

        current_cotent.remove();
        this_li.remove();
        if(this_li.hasClass('active')){
            this_li_prev.addClass('active');
            current_cotent_prev.addClass('active');
        }*/
        CloseTask($(this))
    });

};

//关闭任务单元时
function CloseTask(currentEle){
    var this_li = currentEle.parent().parent();
    var this_li_prev = currentEle.parent().parent().prev();
    var this_li_next = currentEle.parent().parent().next();
    var portlet_id = currentEle.parent().attr('href').substr(1);
    var portlet_id_obj = $('#'+portlet_id+'');
    var current_cotent = 	portlet_id_obj;
    var current_cotent_prev = portlet_id_obj.prev();
    var current_cotent_next = portlet_id_obj.next();


    if(this_li.hasClass('active')){
       // console.log(this_li.prev().length === 0);
        console.log(this_li.prev());
        if(this_li.prev().length !== 0){
            this_li_prev.addClass('active');
            current_cotent_prev.addClass('active');
        }else {
            this_li_next.addClass('active');
            current_cotent_next.addClass('active');
        }
    }

    this_li.remove();
    current_cotent.remove();

}

//更新tree节点
function updateTree(){
    processDispatch.TimeTypeRequest();
    tree.jstree(true).settings.core.data= refreshTimeData;

    var ref = tree.jstree(true);  
    var cbkFun= function(){     //刷新之后的回调（选中第一个）
        var node=ref.get_node(firstTask.tuId);
        ref.deselect_all();
        ref.select_node(node);
    };
    tree.jstree(true).refresh(cbkFun);

}


//计算内容高度
function bodyTaskH(requencyType){
    var portlet = $('.portlet').height();   //总高度
    var portlet_title = $('.portlet-title').outerHeight(true);  //头部高度
    var headerTime = $('.headerTime').outerHeight(true);        //时间点高度
    if(requencyType === 0 || requencyType === 5){
        return  portlet - portlet_title;  //没有时间点剩余高度
    }else {
        return portlet - portlet_title-headerTime;//有时间点剩余高度
    }


}


//数字转换成周几
function weekChange(val){
    var arr1 = [1,2,3,4,5,6,7];
    var arr2 = [7,1,2,3,4,5,6];
    var index = arr1.indexOf(val);
    return arr2[index];
}


</script>
</html>

